package com.bwie.bwedu.model.impl;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.bwie.bwedu.bean.Student;
import com.bwie.bwedu.bean.response.MainInfoResponse;
import com.bwie.bwedu.model.InvalidModel;
import com.bwie.bwedu.volley.RequestAPI;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/7/23.
 */
public class InvalidModelImpl implements InvalidModel {
    @Override
    public void invalid(String flag, String pn, final InvalidListener listener) {
        RequestAPI.getMainInfo(flag, pn, new Response.Listener<MainInfoResponse>() {
            @Override
            public void onResponse(MainInfoResponse mainInfoResponse) {
                if(mainInfoResponse.ok==true) {
                    if (mainInfoResponse.list!=null){
                        listener.onTackSuccess(mainInfoResponse.list);
                    }else{
                        listener.onTackSuccess(new ArrayList<Student>());
                    }


                }else{
                    listener.onTackFail(mainInfoResponse.msg);
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                listener.onTackFail(volleyError.toString());
            }
        });
    }
}
